<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <title>用户列表</title>
</head>
<body>
    <h2>用户列表</h2>
    <table border="1">
        <tr>
            <th>用户名</th>
            <th>姓名</th>
            <th>邮箱</th>
            <th>性别</th>
            <th>生日</th>
            <th>擅长语言</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${userList}" var="user">
            <tr>
                <td>${user.id}</td>
                <td>${user.name}</td>
                <td>${user.email}</td>
                <td>${user.gender}</td>
                <td>${user.birthday}</td>
                <td>${user.lans}</td>
                <td>
                    <a href="editUser?id=${user.id}">编辑</a>
                    <a href="deleteUser?id=${user.id}">删除</a>
                </td>
            </tr>
        </c:forEach>
    </table>

    <!-- 分页导航 -->
    <div>
        <c:if test="${currentPage > 1}">
            <a href="userList?page=${currentPage - 1}">上一页</a>
        </c:if>
        <c:forEach begin="1" end="${totalPages}" var="i">
            <c:choose>
                <c:when test="${currentPage == i}">
                    <span>${i}</span>
                </c:when>
                <c:otherwise>
                    <a href="userList?page=${i}">${i}</a>
                </c:otherwise>
            </c:choose>
        </c:forEach>
        <c:if test="${currentPage < totalPages}">
            <a href="userList?page=${currentPage + 1}">下一页</a>
        </c:if>
    </div>

    <a href="addUser.jsp">添加新用户</a>
</body>
</html>
